package com.test.demo2.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//代替原来的springmvc.xml文件，实现springmvc的自动化配置
@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {
    /**
     * addPathPatterns(/** 指拦截所有)
     * excludePathPatterns(“/“，”/index“ 指排除这里的 "/","/index" 请求)
     * @param registry
     */
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/","/index");
    }
}
